﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#define N 5
int main()
{
	void transfer(int arr[N][N]);
	int arr[N][N] = { 0 };
	int i = 0, j = 0;
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < N; j++)
		{
			scanf("%d", &arr[i][j]);
		}
	}
	transfer(arr);
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < N; j++)
		{
			printf("%d   ", arr[i][j]);
		}
		printf("\n");
	}
	return 0;
}
void transfer(int arr[N][N])
{
	int a = 0, b = 0, c = 0, d = 0, n = arr[0][0], x = arr[0][0], t = 0;
	int i, j;
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < N; j++)
		{
			if (n < arr[i][j])
			{
				n = arr[i][j];
				a = i;
				b = j;
			}
		}
	}//取最大值¦Ì
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < N; j++)
		{
			if (x > arr[i][j])
			{
				x = arr[i][j];
				c = i;
				d = j;
			}
		}
	}//取最小值¦Ì
	t = arr[a][b];
	arr[a][b] = arr[N / 2][N / 2];
	arr[N / 2][N / 2] = t;
	t = arr[c][d];
	arr[c][d] = arr[0][0];
	arr[0][0] = t;
}
//将一个5×5矩阵中最大的元素放在中心，最小的元素放在左上角，写一函数实现之。并用main函数调用。